﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedList test = new SortedList();
            test.Add(1, "佩奇");
            test.Add(2, "乔治");
            test.Add(3, "小猪");
            test.Add(4, "老罗啦");
            Console.WriteLine("请输入编号：");
            int id = int.Parse(Console.ReadLine());
            bool list = test.ContainsKey(id);
            if (list)
            {
                //Console.WriteLine("请输入编号：");
                //int id = int.Parse(Console.ReadLine());
                //string name = test[id].ToString();
                Console.WriteLine("你查询的人姓名为：{0}",test[id].ToString());

                /*if (test.ContainsKey(id))
            {
                Console.WriteLine("你查询的人姓名为：{0}", test[id].ToString());*/
            }
            else
            {
                Console.WriteLine("没有查询到你要的书本！！！");
            }
            foreach (DictionaryEntry h in test)
            {
                int key = (int)h.Key;
                string value = h.Value.ToString();
                Console.WriteLine("图书编号：{0}，图书名称：{1}", key, value);
            }
            
        }
    }
}
